home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / chatr2.zip / IPXLIB.C < prev    next >
C/C++ Source or Header  |  1992-08-31  |  5KB  |  190 lines

  1. /*******************************************************************
  2.  
  3.   IPXLIB.C V1.00
  4.   Copyright (c) 1992 by Kurt Duncan - All Rights Reserved
  5.  
  6.   Library of functions based on the Novell IPX transport mechanism
  7.  
  8. *******************************************************************/
  9.  
  10.  
  11. #include <dos.h>
  12. #include "ipxlib.h"
  13.  
  14.  
  15. /***********************************************************************
  16.   IPX_Is_Loaded
  17. ***********************************************************************/
  18.  
  19. unsigned int IPX_Is_Loaded (void) {
  20.     union  REGS regs;
  21.  
  22.     regs.x.ax = 0x7A00;
  23.     int86 (0x2F, ®s, ®s);
  24.     if (regs.h.al != 0xFF) return (0);
  25.     return (1);
  26.     }
  27.  
  28.  
  29. /***********************************************************************
  30.   IPX_Open_Socket
  31. ***********************************************************************/
  32.  
  33. unsigned int IPX_Open_Socket (unsigned int Socket_Number) {
  34.     union REGS regs;
  35.  
  36.     regs.x.bx = 0x00;    /* IPX function 00h */
  37.     regs.h.al = 0x00;    /* Longevity code 00h (close at end of pgm) */
  38.     regs.x.dx = IPX_Flipword (Socket_Number);
  39.     int86 (0x7A, ®s, ®s);
  40.     return (regs.h.al);
  41.     }
  42.  
  43.  
  44. /***********************************************************************
  45.   IPX_Close_Socket
  46. ***********************************************************************/
  47.  
  48. void IPX_Close_Socket (unsigned int Socket_Number) {
  49.     union REGS regs;
  50.  
  51.     regs.x.bx = 0x01;    /* IPX function 01h */
  52.     regs.x.dx = IPX_Flipword (Socket_Number);
  53.     int86 (0x7A, ®s, ®s);
  54.     return;
  55.     }
  56.  
  57.  
  58. /***********************************************************************
  59.   IPX_Get_Local_Target
  60. ***********************************************************************/
  61.  
  62. unsigned int IPX_Get_Local_Target (struct IPX_address far *Destination,
  63.                                    struct IPX_node    far *Target) {
  64.     union  REGS regs;
  65.     struct SREGS sregs;
  66.  
  67.     segread (&sregs);
  68.     regs.x.bx = 0x02;
  69.     sregs.es  = FP_SEG (Destination);
  70.     regs.x.si = FP_OFF (Destination);
  71.     regs.x.di = FP_OFF (Target);
  72.     int86x (0x7A, ®s, ®s, &sregs);
  73.     return (regs.x.cx);
  74.     }
  75.  
  76.  
  77. /***********************************************************************
  78.   IPX_Send_Packet
  79. ***********************************************************************/
  80.  
  81. void IPX_Send_Packet (struct IPX_ECB far *ECB) {
  82.     union  REGS regs;
  83.     struct SREGS sregs;
  84.  
  85.     segread (&sregs);
  86.     regs.x.bx = 0x03;
  87.     sregs.es  = FP_SEG (ECB);
  88.     regs.x.si = FP_OFF (ECB);
  89.     int86x (0x7A, ®s, ®s, &sregs);
  90.     return;
  91.     }
  92.  
  93.  
  94. /***********************************************************************
  95.   IPX_Listen_For_Packet
  96. ***********************************************************************/
  97.  
  98. void IPX_Listen_For_Packet (struct IPX_ECB far *ECB) {
  99.     union  REGS regs;
  100.     struct SREGS sregs;
  101.  
  102.     segread (&sregs);
  103.     regs.x.bx = 0x04;
  104.     sregs.es  = FP_SEG (ECB);
  105.     regs.x.si = FP_OFF (ECB);
  106.     int86x (0x7A, ®s, ®s, &sregs);
  107.     return;
  108.     }
  109.  
  110.  
  111. /***********************************************************************
  112.   IPX_Cancel_Event
  113. ***********************************************************************/
  114.  
  115. void IPX_Cancel_Event (struct IPX_ECB far *ECB) {
  116.     union  REGS regs;
  117.     struct SREGS sregs;
  118.  
  119.     segread (&sregs);
  120.     regs.x.bx = 0x06;
  121.     sregs.es  = FP_SEG (ECB);
  122.     regs.x.si = FP_OFF (ECB);
  123.     int86x (0x7A, ®s, ®s, &sregs);
  124.     return;
  125.     }
  126.  
  127.  
  128. /***********************************************************************
  129.   IPX_Get_Internetwork_Address
  130. ***********************************************************************/
  131.  
  132. void IPX_Get_Internetwork_Address (struct IPX_address far *Address) {
  133.     union  REGS regs;
  134.     struct SREGS sregs;
  135.  
  136.     segread (&sregs);
  137.     regs.x.bx = 0x09;
  138.     sregs.es  = FP_SEG (Address);
  139.     regs.x.si = FP_OFF (Address);
  140.     int86x (0x7A, ®s, ®s, &sregs);
  141.     return;
  142.     }
  143.  
  144.  
  145. /***********************************************************************
  146.   IPX_Relinquish_Control
  147. ***********************************************************************/
  148.  
  149. void IPX_Relinquish_Control (void) {
  150.     union REGS regs;
  151.  
  152.     regs.x.bx = 0x0A;
  153.     int86 (0x7A, ®s, ®s);
  154.     return;
  155.     }
  156.  
  157.  
  158. /***********************************************************************
  159.   IPX_Flipword
  160. ***********************************************************************/
  161.  
  162. unsigned int IPX_Flipword (unsigned int Inword) {
  163.     unsigned char c1, c2;
  164.  
  165.     c1 = Inword >> 8;
  166.     c2 = Inword & 0xFF;
  167.     return ( (unsigned int) (c2 << 8) | c1);
  168.     }
  169.  
  170.  
  171. /***********************************************************************
  172.   IPX_Fliplong
  173. ***********************************************************************/
  174.  
  175. void IPX_Fliplong (unsigned long *Inlong) {
  176.     unsigned char c1, c2, c3, c4;
  177.  
  178.     c1 = *Inlong >> 24;
  179.     c2 = (*Inlong >> 16) & 0xFF;
  180.     c3 = (*Inlong >> 8) & 0xFF;
  181.     c4 = *Inlong & 0xFF;
  182.  
  183.     *Inlong = (unsigned long) (
  184.               ( (unsigned long) c4 << 24) | 
  185.               ( (unsigned long) c3 << 16) | 
  186.               ( (unsigned long) c2 << 8)  | 
  187.               ( (unsigned long) c1 ));
  188.     return;
  189.     }
  190.